package game.model.items
{
	import game.model.items.vo.ItemVO;
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;

	/**
	 * ...
	 * @author Thot
	 */
	
	public class InventoryProxy extends Proxy implements IProxy
	{
		
		static public var NAME:String = 'InventoryProxy';
		private var _data:Vector.<ItemVO>;
		
		public function InventoryProxy()
		{ 
			_data = new Vector.<ItemVO>();
			super( NAME, _data );
		}
		
		public function addItem( p_item:ItemVO ):void
		{
			_data.push( p_item );
		}
		
		public function getItemBy( p_prop:String, p_value:* ):ItemVO
		{
			var i:int = _data.length;
			var item:ItemVO = null;
			
			while ( --i > -1 )
			{
				item = _data[i];
				if ( item.hasOwnProperty(p_prop) && item[p_prop] == p_value )
					return item;
			}
			
			return null;
		}
		
		
	}

}